<?php echo $this->session->userdata('email'); ?>
<a id="a-popover" class="btn btn-default hidden-xs hidden-sm" data-placement="bottom" data-html="true" data-container="body" data-toggle="popover" data-title="<?= lang('title_access_your_account'); ?>"><i class="icon-user"></i> Login <span class="caret"></span></a>
<div id="div-popover" class="hide popover">
	<div class="message"></div>
	<h3><?=lang("btn_access_your_account")?>:</h3>
	<div class="form-group">
	<div class="input-group">
  		<span class="input-group-addon"><span class="glyphicon glyphicon-envelope"></span></span>
		<input type="text" name="email" class="form-control" placeholder="<?= lang('placeholder_user'); ?>" />
	</div>	
	</div>
	<div class="form-group">
	<div class="input-group">
		<span class="input-group-addon"><span class="glyphicon glyphicon-asterisk"></span></span>
		<input type="password" class="form-control" name="pass" placeholder="<?= lang('placeholder_password'); ?>" onkeypress="formSubmit()" />
	</div>
	</div>
	
	<button class="btn btn-primary" id="login" onclick="login('<?php echo base_url(); ?>')"><?=lang('btn_access')?></button>
	<button class="btn btn-default" href="#myModal" data-toggle="modal" onclick="$('#a-popover').popover('hide')"><?=lang('btn_create_account')?></button>
	<p><a href="<?=base_url()?>forgotpass">Esqueceu sua senha?</a></p>
	<script type="text/javascript">
	function login(base){
	    $.ajax({
	        url : base+'login',
	        type : 'POST', 
	        data : {'email' : $('input[name="email"]').val(), 'pass': $('input[name="pass"]').val()},
	        success : function(data){
	        	 if(data == 'ok'){
	        		 location=base+'profile';
	             }else{
	            	 $('.message').html(data);
	            	 window.setTimeout("$('.alert').alert('close')", 3000); //closes after 3 seconds
	             }
	        }
	    });
	}
	</script>
</div>

